//
//  SXWYRelativeCell.m
//  ShiXun
//
//  Created by lanou on 15/11/3.
//  Copyright © 2015年 张琪. All rights reserved.
//

#import "SXWYRelativeCell.h"
#import "UIImageView+WebCache.h"
@implementation SXWYRelativeCell
- (void)setConfigureModel:(SXWYRelativeModel *)configureModel
{
    _configureModel = configureModel;
    [_coverImg sd_setImageWithURL:[NSURL URLWithString:configureModel.imgsrc] placeholderImage:[UIImage imageNamed:@"SX-placeholder"]];
    _titleLabel.text = configureModel.title;
    _fromLabel.text = [NSString stringWithFormat:@"%@  %@", configureModel.source, [configureModel.ptime substringToIndex:10]];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat imgWidth = (kScreenWidth - 30) / 3 - 20;
        _coverImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, imgWidth, imgWidth * 20 / 27)];
        [self.contentView addSubview:_coverImg];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgWidth + 20, 10, kScreenWidth - imgWidth - 50, imgWidth * 40 / 81)];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = [UIFont systemFontOfSize:15.5];
        _titleLabel.numberOfLines = 2;
        _titleLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_titleLabel];
        
        _fromLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgWidth + 20, imgWidth * 40 / 81 + 10, kScreenWidth - imgWidth - 30, imgWidth * 20 / 81)];
        _fromLabel.font = [UIFont systemFontOfSize:13];
        _fromLabel.textColor = [UIColor grayColor];
        _fromLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_fromLabel];
    }
    return self;
}
+ (CGFloat)heightOfString:(NSString *)labelText
{
    CGRect bounds = [labelText boundingRectWithSize:CGSizeMake(200, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15.5] forKey:NSFontAttributeName] context:nil];
    return bounds.size.height;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
